import { reqGetSearchGoodsInfoData } from "@/api";

const state = {
  goodsInfo: {},
  isPageNo:false
}
const actions = {
  // 1. 获取搜索页面的数据
  async getGoodsInfoData({ commit }, searchParams) {
    const res = await reqGetSearchGoodsInfoData(searchParams)
    // console.log('ss',res)
    if (res.code === 200) {
      commit('SAVE_GOODS_INFO_DATA', res.data)
    } else {
      console.log(res.message)
    }
  }
}
const mutations = {
  // 1. 存储搜索过来的商品信息 是一个对象
  SAVE_GOODS_INFO_DATA(state, goodsInfo) {
    state.goodsInfo = goodsInfo
  }
}
const getters = {
  goodsList(state) {
    return state.goodsInfo.goodsList
  },
  attrsList(state) {
    return state.goodsInfo.attrsList
  },
  trademarkList(state) {
    return state.goodsInfo.trademarkList
  },
  total(state) {
    return state.goodsInfo.total
  }

}


export default {
  namespaced: true, // 启用命名空间 来区分不同的模块
  state,
  actions,
  mutations,
  getters
}